package com.atguigu.redis;

import redis.clients.jedis.Jedis;

/**
 * @author layne
 */
public class JedisTest {
    public static void main(String[] args) {
        //1 创建客户端
        Jedis jedis = new Jedis("hadoop102", 6379);

        //2 使用客户端
        System.out.println(jedis.ping());
        //查看所有key
        System.out.println(jedis.keys("*"));
        //String
        jedis.set("idea","0926");
        System.out.println(jedis.keys("*"));
        System.out.println(jedis.get("idea"));

        //list
        jedis.rpush("l2l","a","b","c","d","e");
        System.out.println(jedis.keys("*"));
        System.out.println(jedis.lrange("l2l", 0, -1));

        //set
        jedis.sadd("s2s","a","b","c","d","e","a","b","c","d","e");
        System.out.println(jedis.keys("*"));
        System.out.println(jedis.smembers("s2s"));

        //hash
        jedis.hset("h2h","name","zs");
        jedis.hset("h2h","age","18");
        jedis.hset("h2h","sex","man");
        System.out.println(jedis.keys("*"));
        System.out.println(jedis.hgetAll("h2h"));


        //3 关闭客户端
        jedis.close();
    }
}
